<?php


// Esta clase a diferencia de la que viene en Zend pasa todos los keys a minuscula.
class Ext_Db_Statement_Mysqli extends Zend_Db_Statement_Mysqli {

    /**
     * Fetches a row from the result set.
     *
     * @param int $style  OPTIONAL Fetch mode for this fetch operation.
     * @param int $cursor OPTIONAL Absolute, relative, or other.
     * @param int $offset OPTIONAL Number for absolute or relative cursors.
     * @return mixed Array, object, or scalar depending on fetch mode.
     * @throws Zend_Db_Statement_Exception
     */
    public function fetch( $style = null, $cursor = null, $offset = null ) {
        $row = parent::fetch( $style, $cursor, $offset );
        return $this->getAdapter()->foldArrayKeys( $row );
    }

    /**
     * Returns an array containing all of the result set rows.
     *
     * @param int $style OPTIONAL Fetch mode.
     * @param int $col   OPTIONAL Column number, if fetch mode is by column.
     * @return array Collection of rows, each in a format by the fetch mode.
     * @throws Zend_Db_Statement_Exception
     */
    public function fetchAll( $style = null, $col = null ) {
        $result = parent::fetchAll( $style, $col );
        foreach ( $result as $key => $val ) {
        	$result[$key] = $this->getAdapter()->foldArrayKeys( $val );
        }
        return $result;
    }

    
    /**
     * Returns a single column from the next row of a result set.
     *
     * @param int $col OPTIONAL Position of the column to fetch.
     * @return string
     * @throws Zend_Db_Statement_Exception
     */
    public function fetchColumn( $col = 0 ) {
        $data = parent::fetchColumn( $col );
        return $data;
    }

    
    /**
     * Fetches the next row and returns it as an object.
     *
     * @param string $class  OPTIONAL Name of the class to create.
     * @param array  $config OPTIONAL Constructor arguments for the class.
     * @return mixed One object instance of the specified class.
     * @throws Zend_Db_Statement_Exception
     */
    public function fetchObject( $class = 'stdClass', array $config = array() ) {
        $obj = parent::fetchObject( $class, $config );
        return $obj;
    }
}
